home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / sys / proc.h < prev    next >
Text File  |  1995-02-14  |  20KB  |  577 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1989 Carnegie-Mellon University
  4.  * Copyright (c) 1988 Carnegie-Mellon University
  5.  * Copyright (c) 1987 Carnegie-Mellon University
  6.  * All rights reserved.  The CMU software License Agreement specifies
  7.  * the terms and conditions for use and redistribution.
  8.  */
  9. /*
  10.  * HISTORY
  11.  * $Log:    proc.h,v $
  12.  * 07-Jan-93  Mac Gillon (mgillon) at NeXT
  13.  *    Integrated POSIX changes
  14.  *
  15.  * Revision 2.10  89/10/11  14:54:00  dlb
  16.  *     Pass thread to thread_should_halt().
  17.  *     [88/10/18            dlb]
  18.  * 
  19.  * Revision 2.9  89/03/15  15:59:42  gm0w
  20.  *     Added pointer to utask to proc structure so that programs
  21.  *     out-side of the kernel can find it without using the task
  22.  *     structure.
  23.  *     [89/03/14            gm0w]
  24.  * 
  25.  * Revision 2.8  89/03/09  22:06:32  rpd
  26.  *     More cleanup.
  27.  * 
  28.  * Revision 2.7  89/02/27  21:04:05  mrt
  29.  *     Made p_rmt_seg field in struct proc unconditional.
  30.  *     [89/02/27            mrt]
  31.  * 
  32.  * Revision 2.6  89/02/25  17:55:23  gm0w
  33.  *     Got rid of MACH and CMUCS conditionals and all non-MACH code.
  34.  *     Made CMUCS conditional code true. Make VICE conditionals
  35.  *     unconditionally false for X75 binary compatibilty, should
  36.  *     be changed to true.
  37.  *     [89/02/13            mrt]
  38.  * 
  39.  * Revision 2.5  89/01/30  22:08:17  rpd
  40.  *     Updated macro definitions to the new style.
  41.  *     Made variable declarations use "extern".
  42.  *     [89/01/25  15:22:29  rpd]
  43.  * 
  44.  * Revision 2.4  88/08/24  02:39:19  mwyoung
  45.  *     Adjusted include file references.
  46.  *     [88/08/17  02:20:09  mwyoung]
  47.  *
  48.  *  4-May-88  David Black (dlb) at Carnegie-Mellon University
  49.  *    Document use of p_stat for MACH.
  50.  *
  51.  * 29-Mar-88  Michael Young (mwyoung) at Carnegie-Mellon University
  52.  *    MACH: Removed unused variables (whichqs).
  53.  *
  54.  * 11-Apr-88  Mike Accetta (mja) at Carnegie-Mellon University
  55.  *    Move controlling terminal information to proc structure from
  56.  *    U-area (to provide better handle on disconnecting background
  57.  *    processes from a terminal);  CS_SECURITY => CMUCS.
  58.  *    [ V5.1(XF23) ]
  59.  *
  60.  * 29-Dec-87  David Golub (dbg) at Carnegie-Mellon University
  61.  *    Delinted.
  62.  *
  63.  * 26-Dec-87  David Golub (dbg) at Carnegie-Mellon University
  64.  *    Removed MACH_NOFLOAT.
  65.  *
  66.  * 21-Dec-87  David Golub (dbg) at Carnegie-Mellon University
  67.  *    Check for thread termination condition and return properly
  68.  *    in more places in sig_lock.
  69.  *
  70.  *  9-Dec-87  David Golub (dbg) at Carnegie-Mellon University
  71.  *    Changed forced_exit case of sig_lock to call thread_halt_self
  72.  *    for new thread termination logic.
  73.  *
  74.  *  3-Dec-87  David Black (dlb) at Carnegie-Mellon University
  75.  *    Added second argument to task_dowait.
  76.  *
  77.  * 18-Nov-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  78.  *    Eliminated MACH conditionals.
  79.  *
  80.  * 28-Oct-87  David Golub (dbg) at Carnegie-Mellon University
  81.  *    MACH_TT: restore definition of SWEXIT to keep ps happy.
  82.  *
  83.  * 16-Oct-87  David Black (dlb) at Carnegie-Mellon University
  84.  *    MACH_TT: Incorporate exit_thread logic in sig_lock() macro.
  85.  *        This replaces and extends core_thread.
  86.  *
  87.  * 25-Sep-87  David Black (dlb) at Carnegie-Mellon University
  88.  *    MACH: added core_thread field to deal with network core dumps.
  89.  *
  90.  * 18-Sep-87  Richard Sanzi (sanzi) at Carnegie-Mellon University
  91.  *    Deleted definition of SOWEFPA, as this condition is no longer
  92.  *    associated with processes, but rather with threads.
  93.  *
  94.  *  4-Sep-87  David Black (dlb) at Carnegie-Mellon University
  95.  *    Added sig lock for signals and exit.  This frees proc lock for
  96.  *    other uses.
  97.  *
  98.  * 15-May-87  David Black (dlb) at Carnegie-Mellon University
  99.  *    MACH: Added p_stopsig field to record signal that stopped
  100.  *    process.  Can't use p_cursig for this purpose under MACH.
  101.  *
  102.  * 30-Mar-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  103.  *    Added a lock to the proc structure to synchronize Unix things in
  104.  *    a multiple thread environement.  This is not conditional on
  105.  *    MACH (but on MACH) so that the same version of ps and friends
  106.  *    will work on both kernels.
  107.  *
  108.  * 06-Mar-87  Mike Accetta (mja) at Carnegie-Mellon University
  109.  *    Changed to use shorts instead of ints for these values that
  110.  *    are really signed chars anyway since its more space efficient
  111.  *    and consistent with the prior fix to p_nice.
  112.  *    [ V5.1(F5) ]
  113.  *
  114.  * 05-Mar-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  115.  *    Make usrpri, pri and nice ints for ROMP due to compiler
  116.  *    difference (this doesn't matter under MACH, but till we run
  117.  *    that everywhere...)
  118.  *
  119.  * 04-Mar-87  Jonathan J. Chew (jjc) at Carnegie-Mellon University
  120.  *    Added pointer to proc structure of tracer for Sun.
  121.  *
  122.  * 02-Mar-87  Mike Accetta (mja) at Carnegie-Mellon University
  123.  *    Fixed to make the p_nice field a short on the IBM-RT since its
  124.  *    current compiler doesn't provide signed char types and this is
  125.  *    wreaking havoc with high priority processes never getting any
  126.  *    cycles!  This fix is only temporary until a better compiler
  127.  *    becomes the standard.
  128.  *    [ V5.1(F4) ]
  129.  *
  130.  *  7-Feb-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  131.  *    Merge VICE changes -- include vice.h and change to #if VICE.
  132.  *
  133.  * 31-Jan-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  134.  *    Eliminate p_wchan for MACH as a check for elimination of all
  135.  *    uses of it.
  136.  *
  137.  * 08-Jan-87  Robert Beck (beck) at Sequent Computer Systems, Inc.
  138.  *    If MACH, declare p_pctcpu as a long and define PCTCPU_SCALE.
  139.  *
  140.  * 31-Dec-86  David Golub (dbg) at Carnegie-Mellon University
  141.  *    Purged all MACH uses of p0br and friends.  Removed fields
  142.  *    that refer to text structure, and removed segment size fields
  143.  *    (p_tsize, p_dsize, p_ssize) that are unused under MACH.
  144.  *    ROMP_FPA should be the next to go (it belongs with the thread info).
  145.  *
  146.  *  2-Dec-86  Jay Kistler (jjk) at Carnegie-Mellon University
  147.  *    VICE: 1/ added p_rmt_seq field to "proc" struct;
  148.  *          2/ added SRMT flag;
  149.  *
  150.  * 31-Oct-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  151.  *    Removed include of task/thread header files by using "struct"
  152.  *    instead of typedef.
  153.  *
  154.  * 15-Oct-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  155.  *    Well, as it turns out, the Multimax code actually does want the
  156.  *    Vax versions of p0br and friends for compatibility.  Presumably
  157.  *    these will all go away someday anyway.
  158.  *
  159.  * 14-Oct-86  William Bolosky (bolosky) at Carnegie-Mellon University
  160.  *    Changed #ifdef romp #else romp {vax code here} #endif romp to
  161.  *    the (correct) #ifdef vax {vax code here} #endif vax.  This
  162.  *    should NOT be changed back again; we now have more machines than
  163.  *    just the vax and the RT, and I don't think that the Sun and the
  164.  *    Encore want definitions of p_p0br.  It's time to fix the scripts.
  165.  *
  166.  * 30-Sep-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  167.  *    Added backpointers from proc to task and thread.
  168.  *
  169.  * 24-Sep-86  Michael Young (mwyoung) at Carnegie-Mellon University
  170.  *    Added include of <sys/types.h> to pick up uid_t, etc.
  171.  *
  172.  *  6-Sep-86  Michael Young (mwyoung) at Carnegie-Mellon University
  173.  *    Added include of <sys/time.h> for non-KERNEL compiles.
  174.  *
  175.  * 20-Jul-86  Michael Young (mwyoung) at Carnegie-Mellon University
  176.  *    Added include of "time.h" to satisfy "struct itimerval"
  177.  *    reference.
  178.  *
  179.  *  7-Jul-86  Bill Bolosky (bolosky) at Carnegie-Mellon University
  180.  *    romp: removed p_sid0 and p_sid1 (since this info is stored in
  181.  *    the pmap and is no longer used).  Conditionalized
  182.  *    SPTECHG on vax and added SOWEFPA in same bit on romp w/FPA.
  183.  *    Conditionalized p0br and p1br on vax.
  184.  *
  185.  * 25-Jan-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  186.  *    Upgraded to 4.3.
  187.  *
  188.  * 18-Feb-86  Bill Bolosky (bolosky) at Carnegie-Mellon University
  189.  *    Added definition of p_sid0 and p_sid1 in proc structure for
  190.  *    IBM-RT under switch romp.
  191.  *
  192.  *  3-Sep-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  193.  *    MACH:  Added SACTIVE flag to signify that a process is actually
  194.  *    running on a cpu.
  195.  *
  196.  * 25-Aug-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  197.  *    Allow recursive includes.
  198.  *
  199.  * 25-May-85  Mike Accetta (mja) at Carnegie-Mellon University
  200.  *    Upgraded from 4.1BSD.  Carried over changes below.
  201.  *    [V1(1)]
  202.  *
  203.  * 20-Aug-81  Mike Accetta (mja) at Carnegie-Mellon University
  204.  *    CMUCS:  added SXONLY bit definition to flag execute only
  205.  *    processes;
  206.  *
  207.  */
  208. /*
  209.  * Copyright (c) 1982, 1986 Regents of the University of California.
  210.  * All rights reserved.  The Berkeley software License Agreement
  211.  * specifies the terms and conditions for redistribution.
  212.  *
  213.  *    @(#)proc.h    7.1 (Berkeley) 6/4/86
  214.  */
  215.  
  216. #ifndef    _SYS_PROC_H_
  217. #define _SYS_PROC_H_
  218.  
  219. #import <mach/boolean.h>
  220. #import <sys/time.h>
  221. #import <sys/types.h>
  222. #import <sys/user.h>
  223. #import <kernserv/lock.h>
  224. #import <mach/machine/vm_types.h>
  225.  
  226. #if POSIX_KERN
  227. #import <mach/machine/vm_types.h>
  228.  
  229. /*
  230.  * One structure allocated per session.
  231.  */
  232. struct    session {
  233.     int    s_count;        /* ref cnt; pgrps in session */
  234.     struct    proc *s_leader;        /* session leader */
  235.     struct    tty *s_ttyp;        /* controlling terminal */
  236.     dev_t   s_ttyd;                 /* controlling tty dev */
  237. };
  238.  
  239. /*
  240.  * One structure allocated per process group.
  241.  */
  242. struct    pgrp {
  243.     struct    pgrp *pg_hforw;        /* forward link in hash bucket */
  244.     struct    proc *pg_mem;        /* pointer to pgrp members */
  245.     struct    session *pg_session;    /* pointer to session */
  246.     pid_t    pg_id;            /* pgrp id */
  247.     int    pg_jobc;    /* # procs qualifying pgrp for job control */
  248. };
  249.  
  250. extern struct pgrp *pgrphash[];
  251. extern struct pgrp *pgfind();
  252.  
  253. #ifdef KERNEL
  254. #define SESS_LEADER(p, px)    ((px)->p_session->s_leader == (p))
  255. #endif /* KERNEL */
  256.  
  257. struct posix_proc {
  258.     pid_t    p_pid;        /* for identification */
  259.  
  260.     uid_t    p_ruid;        /* real user id needed for kill() */
  261.     uid_t    p_svuid;    /* saved set-user-id needed for kill() */
  262.     gid_t    p_svgid;    /* saved set-group-id needed for kill() */
  263.  
  264.     struct proc *p_pgrpnxt;    /* pointer to next process in process group */
  265.     struct pgrp *p_posix_pgrp;    /* pointer to process group */
  266. #define p_pgid        p_posix_pgrp->pg_id
  267. #define p_session       p_posix_pgrp->pg_session
  268.         struct  lockf *p_lockf_chan;    /* Process sleeping on a struct lockf */
  269.                                         /* waiting on an fcntl() file lock. */
  270.     int    p_posix_utime    :  1;
  271.     int    p_posix_noctty   :  1;
  272.     int    p_posix_reserved : 30;
  273.     struct posix_proc *p_next_posix_proc;
  274. };
  275.  
  276. extern struct posix_proc *posix_proc_hash[];
  277. extern struct posix_proc *get_posix_proc();
  278. extern struct posix_proc *new_posix_proc();
  279. extern void          delete_posix_proc();
  280.  
  281. #endif /* POSIX_KERN */
  282.  
  283. /*
  284.  * One structure allocated per active
  285.  * process. It contains all data needed
  286.  * about the process while the
  287.  * process may be swapped out.
  288.  * Other per process data (user.h)
  289.  * is swapped with the process.
  290.  */
  291. struct    proc {
  292.     struct    proc *p_link;    /* linked list of running processes */
  293.     struct    proc *p_rlink;
  294.     struct    proc *p_nxt;    /* linked list of allocated proc slots */
  295.     struct    proc **p_prev;        /* also zombies, and free proc's */
  296. #ifdef    ibmrt
  297.     short    p_usrpri;    /* user-priority based on p_cpu and p_nice */
  298.     short    p_pri;        /* priority, negative is high */
  299.     short    p_cpu;        /* cpu usage for scheduling */
  300. #else    ibmrt
  301.     char    p_usrpri;    /* user-priority based on p_cpu and p_nice */
  302.     char    p_pri;        /* priority, negative is high */
  303.     char    p_cpu;        /* cpu usage for scheduling */
  304. #endif    ibmrt
  305.     char    p_stat;
  306.     char    p_time;        /* resident time for scheduling */
  307. #ifdef    ibmrt
  308.     short    p_nice;        /* nice for cpu usage */
  309. #else    ibmrt
  310.     char    p_nice;        /* nice for cpu usage */
  311. #endif    ibmrt
  312. #if    NeXT
  313.     char    p_debugger    : 1;    /* 1: can exec set-bit programs if */
  314.                     /* suser */
  315.     char    p_posix        : 1; 
  316.         char    p_reserved     : 6;
  317. #else    NeXT
  318.     char    p_slptime;    /* time since last block */
  319. #endif    NeXT
  320.     char    p_cursig;
  321.     int    p_sig;        /* signals pending to this process */
  322.     int    p_sigmask;    /* current signal mask */
  323.     int    p_sigignore;    /* signals being ignored */
  324.     int    p_sigcatch;    /* signals being caught by user */
  325.     int    p_flag;
  326.     uid_t    p_uid;        /* user id, used to direct tty signals */
  327.     short    p_pgrp;        /* name of process group leader */
  328.     short    p_pid;        /* unique process id */
  329.     short    p_ppid;        /* process id of parent */
  330.     u_short    p_xstat;    /* Exit status for wait */
  331.     struct    rusage *p_ru;    /* mbuf holding exit information */
  332. #if    NeXT
  333.     /* These fields are not used. */
  334. #else    NeXT
  335.     size_t     p_rssize;     /* current resident set size in clicks */
  336.     size_t    p_maxrss;    /* copy of u.u_limit[MAXRSS] */
  337.     size_t    p_swrss;    /* resident set size before last swap */
  338.     swblk_t    p_swaddr;    /* disk address of u area when swapped */
  339. #endif    NeXT
  340.     int    p_stopsig;    /* signal that stopped us. */
  341. #if    NeXT
  342.     /* Other elements unused */
  343.     struct    proc    *p_hash;    /* hash table link */
  344. #else    NeXT
  345.     int    p_stopsig;    /* signal that stopped us. */
  346.     short    p_cpticks;    /* ticks of cpu time */
  347.     long    p_pctcpu;    /* %cpu for this process during p_time */
  348.     short    p_ndx;        /* proc index for memall (because of vfork) */
  349.     short    p_idhash;    /* hashed based on p_pid for kill+exit+... */
  350. #endif    NeXT
  351.     struct    proc *p_pptr;    /* pointer to process structure of parent */
  352.     struct    proc *p_cptr;    /* pointer to youngest living child */
  353.     struct    proc *p_osptr;    /* pointer to older sibling processes */
  354.     struct    proc *p_ysptr;    /* pointer to younger siblings */
  355.     struct    itimerval p_realtimer;
  356.     struct    quota *p_quota;    /* quotas for this process */
  357. #if    NeXT
  358.     /* These fields are not used. */
  359. #else    NeXT
  360.     dev_t        p_logdev;    /* logged-in controlling device */
  361.     dev_t       p_ttyd;    /* controlling tty dev */
  362.     struct tty *p_ttyp;    /* controlling tty pointer */
  363. #endif    NeXT
  364.     struct task    *task;    /* corresponding task */
  365. #if    NeXT
  366.     /* utask was only initialized (in kern_fork.c), don't need it. */
  367. #else    NeXT
  368.     struct utask    *utask; /* utask structure of corresponding task */
  369. #endif    NeXT
  370.     struct thread    *thread;/* corresponding thread */
  371. #if    NeXT
  372.     /* not used. */
  373. #else    NeXT
  374.     int    p_rmt_seq;    /* This process is waiting for a remote file 
  375.                    system reply message containing this
  376.                    sequence number - VICE only */
  377.  
  378. #endif    NeXT
  379.     simple_lock_data_t siglock;    /* multiple thread signal lock */
  380.     boolean_t    sigwait;    /* indication to suspend */
  381.     struct thread    *exit_thread;    /* XXX Which thread is exiting?
  382.                        XXX That thread does no signal
  383.                        XXX processing, other threads
  384.                        XXX must suspend. */
  385. #if    NeXT
  386.     struct    proc *p_tptr;    /* pointer to process structure of tracer */
  387.     struct  proc *p_aptr;    /* pointer to process attached to debugger */
  388. #endif    NeXT
  389. #ifdef    sun
  390.     struct    proc *p_tptr;    /* pointer to process structure of tracer */
  391. #endif    sun
  392. #if    NeXT
  393.     vm_offset_t    user_stack;    /* where user stack was allocated */
  394. #endif    NeXT
  395. };
  396.  
  397. #ifdef    KERNEL
  398. #import <kernserv/macro_help.h>
  399.  
  400. /*
  401.  *    Signal lock has the following states and corresponding actions
  402.  *    that the locker must take:
  403.  *
  404.  *    Locked (siglock) - simple lock acquires the lock when free.
  405.  *    Unlocked (sigwait = 0 && exit_thread == 0)  simple lock.
  406.  *    Waiting (sigwait != 0) - Drop siglock after acquiring it, and
  407.  *        call thread_block().  Thread that set the lock to
  408.  *        wait has done a task_suspend().
  409.  *    Exiting (exit_thread != 0) - The thread in exit_thread is going to
  410.  *        call exit().  If we're not that thread, permanently stop
  411.  *        in favor of that thread.  If we're that thread, immediately
  412.  *        bail out (no signal processing is permitted once we're
  413.  *        committed to exit) and indicate that signals should not be
  414.  *        processed.  If we have been asked to halt, bail out and
  415.  *        indicate that signals should be processed (to clean up any
  416.  *        saved state).
  417.  *
  418.  *    The logic for this is in the sig_lock_or_return macro.
  419.  */
  420.  
  421. /*
  422.  *    Try to grab signal lock.  If we are already exiting,
  423.  *    execute 'false_return'.  If some other thread is exiting,
  424.  *    hold.  If we must halt, execute 'true_return'.
  425.  */
  426. #define sig_lock_or_return(p, false_return, true_return)    \
  427. MACRO_BEGIN                            \
  428.     simple_lock(&(p)->siglock);                \
  429.     while ((p)->sigwait || (p)->exit_thread) {        \
  430.         simple_unlock(&(p)->siglock);            \
  431.         if ((p)->exit_thread) {                \
  432.         if (current_thread() == (p)->exit_thread) {    \
  433.             /*                        \
  434.              *    Already exiting - no signals.        \
  435.              */                        \
  436.             false_return;                \
  437.         }                        \
  438.         else {                        \
  439.             /*                        \
  440.              *    Another thread has called exit -    \
  441.              *    stop (until terminate request).        \
  442.              */                        \
  443.             thread_hold(current_thread());        \
  444.         }                        \
  445.         }                            \
  446.         thread_block();                    \
  447.         if (thread_should_halt(current_thread())) {        \
  448.         /*                        \
  449.          *    Terminate request - clean up.        \
  450.          */                        \
  451.         true_return;                    \
  452.         }                            \
  453.         simple_lock(&(p)->siglock);                \
  454.     }                            \
  455. MACRO_END
  456.  
  457. /*
  458.  *    Try to grab signal lock.  Return from caller if
  459.  *    we must halt or task is exiting.
  460.  */
  461. #define sig_lock(p)        sig_lock_or_return(p, return, return)
  462.  
  463. #define sig_lock_simple(p)    simple_lock(&(p)->siglock)
  464.  
  465. #define sig_unlock(p)        simple_unlock(&(p)->siglock)
  466.  
  467. #define sig_lock_to_wait(p)            \
  468. MACRO_BEGIN                    \
  469.     (p)->sigwait = TRUE;             \
  470.     simple_unlock(&(p)->siglock);        \
  471. MACRO_END
  472.  
  473. #define sig_wait_to_lock(p)            \
  474. MACRO_BEGIN                    \
  475.     simple_lock(&(p)->siglock);         \
  476.     (p)->sigwait = FALSE;            \
  477. MACRO_END
  478.  
  479. /*
  480.  *    sig_lock_to_exit() also shuts down all other threads except the
  481.  *    current one.  There is no sig_exit_to_lock().  The sig_lock is
  482.  *    left in exit state and is cleaned up by exit().
  483.  */
  484.  
  485. #define sig_lock_to_exit(p)                \
  486. MACRO_BEGIN                        \
  487.     (p)->exit_thread = current_thread();        \
  488.     simple_unlock(&(p)->siglock);            \
  489.     (void) task_hold(current_task());        \
  490.     (void) task_dowait(current_task(), FALSE);    \
  491. MACRO_END
  492. #endif    KERNEL
  493.  
  494.  
  495. #define PIDHSZ        64
  496. #define PIDHASH(pid)    ((pid) & (PIDHSZ - 1))
  497.  
  498. #ifdef    KERNEL
  499. #if    NeXT
  500. extern struct    proc *pidhash[PIDHSZ];
  501. extern struct    proc *pfind();
  502. extern struct    proc *freeproc, *zombproc, *allproc;
  503.             /* lists of procs in various states */
  504. extern int    max_proc;        /* Max number of procs */
  505. extern struct    proc *kernel_proc, *init_proc;
  506. struct proc    *getproc();
  507. #else    NeXT
  508. extern short    pidhash[PIDHSZ];
  509. extern struct    proc *pfind();
  510. extern struct    proc *proc, *procNPROC;    /* the proc table itself */
  511. extern struct    proc *freeproc, *zombproc, *allproc;
  512.             /* lists of procs in various states */
  513. extern int    nproc;
  514. #endif    NeXT
  515.  
  516. #define NQS    32        /* 32 run queues */
  517. extern struct    prochd {
  518.     struct    proc *ph_link;    /* linked list of running processes */
  519.     struct    proc *ph_rlink;
  520. } qs[NQS];
  521.  
  522. #define PCTCPU_SCALE    1000    /* scaling for p_pctcpu */
  523. #endif    KERNEL
  524.  
  525. /* stat codes */
  526. /*
  527.  *    MACH uses only NULL, SRUN, SZOMB, and SSTOP.
  528.  */
  529. #define SSLEEP    1        /* awaiting an event */
  530. #define SWAIT    2        /* (abandoned state) */
  531. #define SRUN    3        /* running */
  532. #define SIDL    4        /* intermediate state in process creation */
  533. #define SZOMB    5        /* intermediate state in process termination */
  534. #define SSTOP    6        /* process being traced */
  535.  
  536. /* flag codes */
  537. #define SLOAD    0x00000001    /* in core */
  538. #define SSYS    0x00000002    /* swapper or pager process */
  539. #define SLOCK    0x00000004    /* process being swapped out */
  540. #define SSWAP    0x00000008    /* save area flag */
  541. #define STRC    0x00000010    /* process is being traced */
  542. #define SWTED    0x00000020    /* another tracing flag */
  543. #define SULOCK    0x00000040    /* user settable lock in core */
  544. #define SPAGE    0x00000080    /* process in page wait state */
  545. #define SKEEP    0x00000100    /* another flag to prevent swap out */
  546. #define SOMASK    0x00000200    /* restore old mask after taking signal */
  547. #define SWEXIT    0x00000400    /* working on exiting */
  548. #define SPHYSIO    0x00000800    /* doing physical i/o (bio.c) */
  549. #define SVFORK    0x00001000    /* process resulted from vfork() */
  550. #define SVFDONE    0x00002000    /* another vfork flag */
  551. #define SNOVM    0x00004000    /* no vm, parent in a vfork() */
  552. #define SPAGI    0x00008000    /* init data space on demand, from inode */
  553. #define SSEQL    0x00010000    /* user warned of sequential vm behavior */
  554. #define SUANOM    0x00020000    /* user warned of random vm behavior */
  555. #define STIMO    0x00040000    /* timing out during sleep */
  556. /* was SDETACH */
  557. #define SACTIVE    0x00080000    /* process is executing */
  558. #define SOUSIG    0x00100000    /* using old signal mechanism */
  559. #define SOWEUPC    0x00200000    /* owe process an addupc() call at next ast */
  560. #define SSEL    0x00400000    /* selecting; wakeup/waiting danger */
  561. #define SLOGIN    0x00800000    /* a login process (legit child of init) */
  562.  
  563. #define SXONLY    0x02000000    /* process image read protected    */
  564. #define SIDLE    0x04000000    /* is an idle process */
  565. #define SRMT    0x10000000    /* VICE remote file system access--don't stop job */
  566.  
  567. #if POSIX_KERN
  568. #define SCTTY   0x40000000      /* has a controlling terminal */
  569. #define SEXEC    0x80000000    /* process called exec */
  570. #endif /* POSIX_KERN */
  571.  
  572. #if    NeXT
  573. #define SLKDONE    0x20000000    /* record-locking has been done */
  574. #endif    NeXT
  575.  
  576. #endif    _SYS_PROC_H_
  577.